package com.osce.basic.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csce.domain.entity.basic.BasicSchool;
import com.osce.basic.mapper.BasicSchoolMapper;
import com.osce.common.utils.DateUtils;
import com.osce.interfaces.basic.IBasicSchoolService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 学校表Service业务层处理
 *
 * @author zzx
 * @since 2023-07-18
 */
@Service
public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, BasicSchool> implements IBasicSchoolService {


    /**
     * 查询学校表
     *
     * @param id 学校表主键
     * @return 学校表
     */
    @Override
    public BasicSchool selectBasicSchoolById(Long id) {
        return baseMapper.selectBasicSchoolById(id);
    }

    /**
     * 查询学校表列表
     *
     * @param basicSchool 学校表
     * @return 学校表
     */
    @Override
    public List<BasicSchool> selectBasicSchoolList(BasicSchool basicSchool) {
        return baseMapper.selectBasicSchoolList(basicSchool);
    }

    /**
     * 新增学校表
     *
     * @param basicSchool 学校表
     * @return 结果
     */
    @Override
    public int insertBasicSchool(BasicSchool basicSchool) {
        basicSchool.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertBasicSchool(basicSchool);
    }

    /**
     * 修改学校表
     *
     * @param basicSchool 学校表
     * @return 结果
     */
    @Override
    public int updateBasicSchool(BasicSchool basicSchool) {
        return baseMapper.updateBasicSchool(basicSchool);
    }

    /**
     * 批量删除学校表
     *
     * @param ids 需要删除的学校表主键
     * @return 结果
     */
    @Override
    public int deleteBasicSchoolByIds(Long[] ids) {
        return baseMapper.deleteBasicSchoolByIds(ids);
    }

    /**
     * 删除学校表信息
     *
     * @param id 学校表主键
     * @return 结果
     */
    @Override
    public int deleteBasicSchoolById(Long id) {
        return baseMapper.deleteBasicSchoolById(id);
    }

    @Override
    public Map<String, Long> selectAllIdToMap() {
        return new HashMap<String, Long>() {{
            baseMapper.selectAllToMap().forEach((k, v) -> put(k, v.getId()));
        }};
    }
}
